package com.my.design.structural.proxy.JdkProxy;

import java.lang.reflect.*;

/**
 * @author 代廷波
 * @className: JdkProyx
 * @description: jdk代理类
 * @create 2018/12/21 0021-11:03
 **/
public class JdkProyx implements InvocationHandler {
    // 代理的对象
    private Object target;

    public JdkProyx(Object target) {
        super();
        this.target = target;
    }
    /**
     * @param proxy 被代理对象
     * @return java.lang.Object 反回值
     * @author 代廷波
     * @description:
     * @param: method 被代理方法
     * @param: args 方法的参数
     * @create 2018-12-21 11:07
     **/
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("JDK动态代理开始记录访问时间--" + System.currentTimeMillis());
        System.out.println(args);
        method.invoke(target, args);
        System.out.println("JDK动态代理完成---" + System.currentTimeMillis());
        return null;
    }
}
